<script lang="jsx" setup>
import { ref } from 'vue';
import Form from '@/components/common/form.vue';

const props = defineProps({
  rowData: {
    type: Object,
    default: () => null
  }
});

console.log('props.rowData:', props.rowData);

function getModal() {
  if (props.rowData) {
    const { operator, operatorTime, evenReason, evenSolution } = props.rowData;
    return { operator, operatorTime, evenReason, evenSolution };
  }
  return {
    operator: null,
    operatorTime: null,
    evenReason: null,
    evenSolution: null
  };
}

const model = ref(getModal());

const formList = [
  {
    type: 'tabs',
    name: '基本信息',
    span: 24
  },
  {
    type: 'input',
    key: 'operator',
    disabled: true,
    label: '处理人',
    placeholder: '请输入处理人',
    span: 24
  },

  {
    type: 'datePicker',
    key: 'operatorTime',
    label: '处理时间',
    span: 24,
    showTime: true
  },
  {
    type: 'textarea',
    key: 'evenReason',
    label: '原因分析',
    placeholder: '请输入原因分析',
    span: 24
  },
  {
    type: 'textarea',
    key: 'evenSolution',
    label: '改善措施',
    placeholder: '请输入改善措施',
    span: 24
  }
];

defineExpose({
  model: model.value
});
</script>

<template>
  <div class="event-form">
    <Form v-model:model="model" :form-list="formList"></Form>
  </div>
</template>

<style lang="scss" scoped></style>
